from pyarrow import fs
local = fs.LocalFileSystem()

# 写文件
with local.open_output_stream('/tmp/local_fs.dat') as stream:
    stream.write(b'data')
# 读取文件
with local.open_input_stream('/tmp/local_fs.dat') as stream:
    print(stream.readall())

from pathlib import Path
import tempfile
from ray.train import Checkpoint
# temp_dir = tempfile.mkdtemp()
# print(temp_dir)
# (Path(temp_dir) / "example.txt").write_text("example checkpoint data 111111111111111111")
# 复制目录到临时目录中.
temp_dir = "/home/Dyf/code/llamafactory"
# 读取固定目录下的文件并拷贝到临时目录中.
# 固定目录以 checkpoint开头.
checkpoint = Checkpoint.from_directory(temp_dir)
print("checkpoint",checkpoint)
print(checkpoint.to_directory())
